<template>
  <div>
    <div>
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>数据统计</el-breadcrumb-item>
        <el-breadcrumb-item>数据报表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-card>
      <!-- 准备盒子具备宽高 -->
      <div id="main" style="width: 600px;height:400px;"></div>
    </el-card>
  </div>
</template>

<script>
// 导入echarts
import * as echarts from 'echarts'
// 导入lodash
import _ from 'lodash'
export default {
  data() {
    return {
      options: {
        title: {
          text: '用户来源'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#E9EEF3'
            }
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            boundaryGap: false
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ]
      }
    }
  },
  created() {},
  methods: {},
  async mounted() {
    // 初始化ech
    var mycharts = echarts.init(document.getElementById('main'))
    // var mycharts = echarts.init(this.$refs.mainrefs)
    // 数据和配置
    // 发送请求
    const { data: res } = await this.$http.get('reports/type/1')
    console.log(res.data)
    if (res.meta.status !== 200) {
      return this.$message.error('获取折线图数据失败')
    }
    const result = _.merge(res.data, this.options)
    mycharts.setOption(result)
  }
}
</script>

<style></style>
